<?php defined('In33hao') or exit('Access Invalid!');?>

<div class="page">
  <div class="fixed-bar">
    <div class="item-title">
      <div class="subject">
        <h3><?php echo $lang['web_set'];?></h3>
        <h5><?php echo $lang['web_set_subhead'];?></h5>
      </div>
      <?php echo $output['top_link'];?> </div>
  </div>
  <!-- 操作说明 -->
  <div class="explanation" id="explanation">
    <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
      <h4 title="<?php echo $lang['nc_prompts_title'];?>"><?php echo $lang['nc_prompts'];?></h4>
      <span id="explanationZoom" title="<?php echo $lang['nc_prompts_span'];?>"></span> </div>
    <ul>
      <li>更换管理后台登录手机验证号码</li>
      <li>更换成功后请使用更换的手机号码进行登录管理后台。</li>
    </ul>
  </div>
  <form method="post" enctype="multipart/form-data" name="form1">
    <input type="hidden" name="form_submit" value="ok" />
    <div class="ncap-form-default">
      <dl class="row">
        <dt class="tit">
          <label for="site_name">手机号码</label>
        </dt>
        <dd class="opt">
          <input id="mobile" name="mobile" value="<?php echo $output['admin_mobie'];?>" class="input-txt" type="text" /><div class="sendSmsBox">
            <a href="javascript:;" class="sendBtn">发送验证码</a><span class="tips">手机号不能为空</span><span class="success">短信验证码已发送至该手机,<span>60</span>s 可重新发送</span></div>
          <p class="notic">用于管理后台安全登录</p>
        </dd>
      </dl>
      <dl class="row" id="auth_code" style="display: none">
            <dt class="tit">
                <label for="site_name">短信动态码</label>
            </dt>
            <dd class="opt">
                <input id="auth_code" name="auth_code" value="" class="input-txt" type="text" />
                <p class="notic">输入手机接收到的短信验证码</p>
            </dd>
        </dl>
      <div class="bot"><a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="document.form1.submit()"><?php echo $lang['nc_submit'];?></a></div>
    </div>
  </form>
</div>
<script type="text/javascript">
     $(".sendBtn").click(function(){
          var mobile = $('#mobile').val();
          if (mobile==''){
            showTips('手机号不能为空');
            return;
          }
          var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
          if (!myreg.test(mobile)){
             showTips('请填写正确的手机号码');
             return;
          }
          $.ajax({
             type:"POST",
             url:"./index.php?act=setting&op=sendSms",
             data:{mobile:mobile},
             dataType:"json",
             success:function(data){
                if(data['status']==200){
                    document.getElementsByClassName('sendBtn')[0].className = 'noSendBtn';
                    $('#auth_code').show();
                    showTimes()
                }else{
                    showTips("短信验证码发送失败");
                }
             }
          })
     })

     function showTimes(){
          $(".success").show();
          var tims = 60;
          var timer = null;
          timer = setInterval(function(){
               if(tims==0){
                    clearInterval(timer);
                    $(".success").hide();
                    document.getElementsByClassName('noSendBtn')[0].className = 'sendBtn';
                    return;
               }
               tims--;
               $('.success span').html(tims);
          },1000)
     }

     function showTips(html){
          $('.tips').html(html);
          $('.tips').show();
     }
</script> 
